package com.cqie.controller.medical;

import com.cqie.dto.medical.MedicalPublicationDto;
import com.cqie.entity.MedicalPublication;
import com.cqie.exception.SpecialException;
import com.cqie.service.IMedicalPublicationService;
import com.cqie.util.ResultTemplate;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 公告信息表 前端控制器
 * </p>
 *
 * @author 不吃海鲜
 * @since 2024-12-04
 */
@Tag(name = "公告信息Controller", description = "描述：公告信息接口")

@RestController
@RequestMapping({"/api/v1.0/medicalPublication", "/api/v1/medicalPublication"})
public class MedicalPublicationController {

    private final IMedicalPublicationService medicalPublicationService;

    public MedicalPublicationController(IMedicalPublicationService medicalPublicationService) {
        this.medicalPublicationService = medicalPublicationService;
    }

    @Operation(summary = "新增 / 更新 公告信息")
    @PostMapping("/saveMedicalPublication")
    public ResultTemplate<Boolean> saveMedicalPublication(@RequestBody MedicalPublicationDto medicalPublicationDto) throws SpecialException {
        return ResultTemplate.Success(medicalPublicationService.saveMedicalPublication(medicalPublicationDto));
    }

    @Operation(summary = "查询公告信息List")
    @GetMapping("/getMedicalPublicationList")
    public ResultTemplate<List<MedicalPublicationDto>> getMedicalPublication(String publicationType) {
        return ResultTemplate.Success(medicalPublicationService.getMedicalPublicationList(publicationType));
    }

    @Operation(summary = "根据id查询公告信息")
    @GetMapping("/getMedicalPublicationById")
    public ResultTemplate<MedicalPublication> getMedicalPublicationById(Integer publicationId) {
        return ResultTemplate.Success(medicalPublicationService.getById(publicationId));
    }

    @Operation(summary = "删除公告信息")
    @GetMapping("/deleteMedicalPublication")
    public ResultTemplate<Boolean> deleteMedicalPublication(Integer publicationId) {
        return ResultTemplate.Success(medicalPublicationService.deleteMedicalPublication(publicationId));
    }
}
